package com.linyaonan.leetcode.medium._1490;

import java.util.ArrayList;

class Solution {
    public Node cloneTree(Node root) {
        if (root == null) {
            return null;
        }
        ArrayList<Node> addChild = new ArrayList<>();
        for (Node child : root.children) {
            addChild.add(cloneTree(child));
        }
        Node result = new Node(root.val, addChild);
        return result;
    }
}